package com.weigj.controller;

import com.google.common.base.Strings;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.weigj.model.CarInfo;

public class CarController extends Controller {

	public void queryCar()
	{
		String carNo = getPara("carInfo.infolicense");
		String infoframcode = getPara("carInfo.infoframcode");
		CarInfo carInfo = new CarInfo();
		String param = null;
		if (!Strings.isNullOrEmpty(carNo))
		{
			param = carNo;
		} else
		{
			param = infoframcode;
		}
		carInfo = carInfo.queryCarInfo(param);
		if (carInfo != null)
		{
			// 根据车辆查询所属车型
			String sql = "select t.* from APP_TOPCARMODEL t where t.TCM_ID=?";
			Record record = Db.findFirst(sql, carInfo.get("topcarmodelid"));
			carInfo.put("tcm_wholename", record.get("tcm_wholename"));
		}
		setAttr("carInfo", carInfo);
		render("/car.jsp");
	}
}
